<template>
  <div class="header">
    <!-- 矢量图标？ -->
    <div class="header-left"><span class="iconfont">&#xe624;</span></div>
    <div class="header-input"><span class="iconfont">&#xe632;</span>新人大礼包</div>
    <!-- div 被 routerlink 包裹之后渲染成了 a 标签 -->
    <router-link to="/city">
      <div class="header-right">
        <!-- mapState -->
        {{this.city}}
        <span class="iconfont">&#xe62a;</span>
      </div>
    </router-link>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  name: 'homeHeader',
  computed: {
    // mapState ?
    ...mapState(['city'])
  }
}
</script>

<style scoped>
  .header {
    display: flex;
    /* 43px == .86rem */
    height: 43px;
    line-height: 43px;
    background-color: #00bcd4;
    color: #fff;
  }
  .header-left {
    width: 32px;
    /* float: left; */
    text-align: center;
  }
  .header-input {
    flex: 1;
    background: #fff;
    height: 32px;
    line-height: 32px;
    color: #ccc;
    border-radius: 5px;
    margin-top: 6px;
    margin-left: 4px;
    padding-left: 14px;
  }
  /* 搜索框和新人大礼包保持距离 */
  .header-input .iconfont {
    margin-right: 5px;
  }
  .header-right {
    /* 这是个啥原理，宽度可变？ */
    min-width: 52px;
    padding: 0 5px;
    float: right;
    text-align: center;
    color: white;
    /* 文字溢出显示 ... */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .header-right .iconfont {
    margin-left: 3px;
    font-size: 12px;
  }
</style>
